<?php
declare (strict_types = 1);

namespace app\model;

use app\traits\CreationLimitTrait;
use think\Model;
use think\model\relation\HasMany;

/**
 * @mixin Model
 */
class OrganizationRoles extends Model
{
    use CreationLimitTrait;
    // 设置主键
    protected $pk = 'id';

    public function getPermissionsAttr($value)
    {
        if ($value){
            return json_decode($value, true);
        }else{
            return [];
        }
    }
    /**
     * 关联团队成员
     */
    public function members(): HasMany
    {
        return $this->hasMany(OrganizationMembers::class, 'role_id', 'id');
    }
}
